
<!DOCTYPE html>
<html lang='en-US'>
    <head>
        <!--Document title is project name-->
        <title>NatCorder Scripting Reference on Calligraphy</title>
        <!--Extra information-->
        <meta name='description' content='NatCorder API documentation on Calligraphy'> <!--Populate from Calligraphy-->
        <meta name='keywords' content='NatCorder, Calligraphy, Unity'> <!--Populate from Calligraphy-->
        <meta name='author' content='Calligraphy by Yusuf Olokoba'>
        <meta charset='UTF-8'>
        <!--Style sheet-->
        <link rel='stylesheet' href='../Styles/memberstyles.css'>
    </head>
	
	<body>
        <h1 class='blockname'><a href='../Groups/MP4Recorder.html'>MP4Recorder</a>.CommitFrame</h1>
        <p1 class='faintname'>public  void CommitFrame (RenderTexture frame, long timestamp)<b>;</b></p1>
        <br>
        <br>
        <h2>Description</h2>
        <p1>Commit a video frame for encoding.<br><br>
            Note that all frames that have been previously acquired must be committed. Also note that a frame must 
            not be committed more than once. Doing so will lead to undefined behaviour and possibly a crash.<br><br>
            Note that WebGL is an immediate-encode platform, meaning that frames are encoded immediately 
            they are committed. As a result, timestamps on video frames and audio sample buffers are wholly ignored.</p1>
        <br>
        <br>
        
        <!--Code example-->
        <!--Must not be indented-->
        <!--There must be no space between the text and the pre tags-->

<code>
<pre>public class RecordCamera : MonoBehaviour {

    WebCamTexture cameraTexture;
    IMediaRecorder mediaRecorder;
    IClock clock;
       
    IEnumerator Start () {
        <font color='green'>// Start camera preview</font>
        cameraTexture = new WebCamTexture();
        cameraTexture.Play();
        <font color='green'>// Start recording</font>
        clock = new RealtimeClock();
        mediaRecorder = new ... <font color='green'>// Create a recorder</font>
        <font color='green'>// Wait a while</font>
        yield return new WaitForSeconds(10f);
        <font color='green'>// Stop recording</font>
        mediaRecorder.Dispose();
        mediaRecorder = null;
    }
    
    void Update () {
        if (mediaRecorder != null && cameraTexture.didUpdateThisFrame) {
            <font color='green'>// Acquire a video frame</font>
            var frame = mediaRecorder.AcquireFrame();
            <font color='green'>// Blit the camera preview frame to the video frame</font>
            Graphics.Blit(cameraTexture, frame);
            <font color='green'>// Commit the frame for encoding</font>
            mediaRecorder.CommitFrame(frame, clock.Timestamp);
        }
    }

}</pre>
</code>
<br>
        
        
        <!--See Also-->
        
        
        <!--Copyright tag-->
        <br>
        <hr>
        <p1 class='copyright'><small>Copyright (c) Yusuf Olokoba 2016</small></p1>
        
	</body>
</html>        
        